package org.example.io;

import org.example.io.pojo.User;

import java.io.FileInputStream;
import java.io.ObjectInputStream;

public class TestObjectInputStream {
    public static void main(String[] args) throws Exception {
        //创建反序列化输入流
        ObjectInputStream stream = new ObjectInputStream(new FileInputStream("D:\\tmp\\user.txt"));
        //读取数据
        User user = (User) stream.readObject();
        //打印数据
        System.out.println(user.toString());
        //关闭流
        stream.close();
    }
}
